<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <input type="hidden" id="matchid" value="{$match.id}">
            <div class="layui-card">
                <div class="layui-card-header">
                    {$match.hometeam.name_zh} VS {$match.awayteam.name_zh}</div>
                <div class="layui-card-body">
                    比赛时间：<?php echo (date("Y-m-d h:i:s",$match['time'])); ?>
                </div>
            </div>

            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-matchanchor" data-type="add">添加</button>
            </div>

            <table id="LAY-football-matchanchor-manage" lay-filter="LAY-football-matchanchor-manage"></table>

            <script type="text/html" id="table-matchanchor-list">
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>取消关联</a>
            </script>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'admin', 'football', 'table'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table
            ,admin = layui.admin;

        //事件
        var active = {
            add: function(){
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请输入主播id，多个请用英文,隔开',
                    area: ['800px', '350px'] //自定义文本域宽高
                }, function(value, index, elem){
                    admin.req({
                        url: '/admin/football/addmatchanchor_post'
                        ,data: {"ids":value,'matchid':$("#matchid").val()}
                        ,success(res){
                            if (res.code == 0){
                                table.reload("LAY-football-matchanchor-manage");
                                layer.msg(res.msg, {icon:1});
                            } else{
                                layer.msg(res.msg, {icon:5});
                            }
                        }
                    });
                    layer.close(index);
                });
            }
        };

        $('.layui-btn.layuiadmin-btn-matchanchor').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听搜索
        form.on('submit(LAY-football-front-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-football-manage', {
                where: field
                , page: {
                    curr: 1   //默认从第一页开始搜索
                },
            });
        });
    });
</script>
</body>
</html>
